package com.socket;


import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

public class MyServer {
    public static final int MY_SERVER_PORT = 8081;
    public static final Charset MY_COMM_CHARSET = StandardCharsets.UTF_8;
    public static final String BYE = "bye";

    public static void main(String[] args) throws IOException {
        commonWithClient();
    }

    private static void commonWithClient() {
        try(
                ServerSocket ss = new ServerSocket(MY_SERVER_PORT);
                Socket s = ss.accept();
        ) {
                Chat chat = new Chat("客户端", "你已经连接上服务器端了", s);
                chat.chatting();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
